#include "globalParameters.h"
#include <iostream>
#include <cmath>

using namespace std;

GlobalParameters::GlobalParameters(int cwmn, int cwmx, double sltTime, double difsTime, double csThrld, double receptionThrshld, int simTime, int pckSz, double bitRt){
	cwMin = cwmn;
	cwMax = cwmx;
	slotTime = sltTime;
	difs = difsTime;
	csThreshold = csThrld;
	receptionThreshold = receptionThrshld;
	simulationTime = simTime;
	packetSize = pckSz;
	bitRate = bitRt;
	slotsPerPacket = ceil(((pckSz*8)/(bitRate*pow(2.0,20.0)))*pow(10.0,6.0)/slotTime);
}

void GlobalParameters::print(){
	cout << "cwMin: " << cwMin << " slots\n";
	cout << "cwMax: "  << cwMax << " slots\n";
	cout << "slotTime: " << slotTime << " micro seconds\n";
	cout << "difs: " << difs << " micro seconds\n";
	cout << "csThreshold: " << csThreshold << " Watts\n";
	cout << "receptionThreshold: " << receptionThreshold << " Watts\n";
	cout << "simulationTime: " << simulationTime << " slots\n";
	cout << "packetSize: " << packetSize << " bytes\n";				
	cout << "bitRate: " << bitRate << " Mbps\n";
	cout << "slotsPerPacket: " << slotsPerPacket << endl;
}

int GlobalParameters::getCwMin(){

	return cwMin;
}

int GlobalParameters::getCwMax(){
	return cwMax;
}

double GlobalParameters::getDIFS(){
	return difs;
}

double GlobalParameters::getCsThreshold(){
	return csThreshold;
}

double GlobalParameters::getReceptionThreshold(){
	return receptionThreshold;
}

int GlobalParameters::getSimulationTime(){
	return simulationTime;
}

int GlobalParameters::getSlotsPerPacket(){
	return slotsPerPacket;
}

int GlobalParameters::getSlotTime(){
	return slotTime;
}

void GlobalParameters::setSlotTime(int inputSlotTime){
	slotTime = inputSlotTime;
}
